<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    888. Mirror Reflection
   </h1>
   <p>
    There is&nbsp;a special square room with mirrors on each of the four&nbsp;walls.&nbsp; Except for the southwest&nbsp;corner, there are receptors on each of the remaining corners, numbered
    <code>
     0
    </code>
    ,
    <code>
     1
    </code>
    , and
    <code>
     2
    </code>
    .
   </p>
   <p>
    The square room has walls of length
    <code>
     p
    </code>
    , and a laser ray from the southwest corner&nbsp;first meets the east wall at a distance
    <code>
     q
    </code>
    &nbsp;from the
    <code>
     0
    </code>
    th receptor.
   </p>
   <p>
    Return the number of the receptor that the ray meets first.&nbsp; (It is guaranteed that the ray will meet&nbsp;a receptor eventually.)
   </p>
   <p>
    &nbsp;
   </p>
   <div>
    <p>
     <strong>
      Example 1:
     </strong>
    </p>
    <pre>
<strong>Input: </strong>p = <span id="example-input-1-1">2</span>, q = <span id="example-input-1-2">1</span>
<strong>Output: </strong><span id="example-output-1">2</span>
<strong>Explanation: </strong>The ray meets receptor 2 the first time it gets reflected back to the left wall.
<p><img alt="" src="https://ibb.co/mYSFJT"><img alt="" src="https://s3-lc-upload.s3.amazonaws.com/uploads/2018/06/18/reflection.png" style="width: 218px; height: 217px;"></p>
</pre>
    <p>
     <strong>
      Note:
     </strong>
    </p>
    <ol>
     <li>
      <code>
       1 &lt;= p &lt;= 1000
      </code>
     </li>
     <li>
      <code>
       0 &lt;= q &lt;= p
      </code>
     </li>
    </ol>
   </div>
  </div>
  <div>
   <h1 class="question_title">
    888. 镜面反射
   </h1>
   <p>
    有一个特殊的正方形房间，每面墙上都有一面镜子。除西南角以外，每个角落都放有一个接受器，编号为&nbsp;
    <code>
     0
    </code>
    ，&nbsp;
    <code>
     1
    </code>
    ，以及&nbsp;
    <code>
     2
    </code>
    。
   </p>
   <p>
    正方形房间的墙壁长度为&nbsp;
    <code>
     p
    </code>
    ，一束激光从西南角射出，首先会与东墙相遇，入射点到接收器
    <code>
     0
    </code>
    的距离为
    <code>
     q
    </code>
    。
   </p>
   <p>
    返回光线最先遇到的接收器的编号（保证光线最终会遇到一个接收器）。
   </p>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     示例：
    </strong>
   </p>
   <pre><strong>输入： </strong>p = 2, q = 1
<strong>输出： </strong>2
<strong>解释： </strong>这条光线在第一次被反射回左边的墙时就遇到了接收器 2 。
<img alt="" src="https://ibb.co/mYSFJT"><img alt="" src="https://aliyun-lc-upload.oss-cn-hangzhou.aliyuncs.com/aliyun-lc-upload/uploads/2018/06/22/reflection.png" style="height: 217px; width: 218px;"></pre>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     提示：
    </strong>
   </p>
   <ol>
    <li>
     <code>
      1 &lt;= p &lt;= 1000
     </code>
    </li>
    <li>
     <code>
      0 &lt;= q &lt;= p
     </code>
    </li>
   </ol>
  </div>
 </body>
</html>